package com.runvp.common.enums;

/**
 * 发送消息
 *
 */
public enum MsgType {
    FOOT("FFFF", "报文固定结尾"),
    DS("3A3A", "客户端/服务器发送"),
    SD("3A3A", "业务客户端向服务器发送指令");
    private String code;    //类型
    private String message;    //描述

    private MsgType(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 是否包含枚举key值
     *
     * @param key
     * @return boolean true：包含，  false：不包含
     */
    public static boolean isContains(String key) {
        if(null == key || "".equals(key)){return  false ;}
        for (MsgType e: MsgType.values()){
            if(key.equals(e.getCode())){
                return true;
            }
        }
        return false;
    }

    /**
     * 根据key获取对应value
     * @param key
     * @return str
     */
    public static String getValue(String key) {
        if(null == key || "".equals(key)){return  "未知" ;}
        for (MsgType e: MsgType.values()){
            if(key.equals(e.getCode())){
                return e.getMessage();
            }
        }
        return "未知";
    }
}
